package com.examples.springboot.jpa.gui.department;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import com.examples.springboot.jpa.pojos.DepartmentDto;

/**
 * A custom renderer for cells in the Mount column.
 *
 */
@SuppressWarnings("serial")
public class DepartmentCellRenderer extends DefaultTableCellRenderer {
	
 	public Component getTableCellRendererComponent(JTable table, Object value, 
 			boolean isSelected, boolean hasFocus, int row, int column) {
 		if (value instanceof DepartmentDto) {
 		 DepartmentDto department = (DepartmentDto) value;
 			setText(department.getName());
 		}else if(value instanceof String) {
 		  setText((String)value);
 		}

 		if (isSelected) {
 			setBackground(table.getSelectionBackground());
 		} else {
      setBackground(/* table.getSelectionForeground() */Color.WHITE);
 		}
 		
 		return this;
 	}
 	
}
